import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:juming_test/config/home_images.dart';

class HomeFinance extends StatelessWidget {
  const HomeFinance({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.all(16.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '财务中心',
            style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold),
          ),
          SizedBox(height: 10.w),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                padding: EdgeInsets.all(16.w),
                width: 175.w,
                height: 150.w,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(8),
                  image: DecorationImage(
                    image: AssetImage(HomeImages.homeFinancialZjePng),
                    fit: BoxFit.cover,
                  ),
                ),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('总金额（元）', style: TextStyle(fontSize: 16.sp)),
                    Text(
                      '¥ 1,6888.09',
                      style: TextStyle(
                        fontSize: 24.sp,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    SizedBox(
                      width: double.infinity,
                      height: 40.w,
                      child: OutlinedButton(
                        style: OutlinedButton.styleFrom(
                          side: BorderSide(color: Color(0xFFD5A771)),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(8),
                          ),
                        ),
                        onPressed: () {},
                        child: Text(
                          '在线充值',
                          style: TextStyle(
                            fontSize: 14.sp,
                            color: Color(0xFFD5A771),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  _buildFinanceButton(
                    '资金明细',
                    HomeImages.homeFinancialZjmxPng,
                    true,
                  ),
                  SizedBox(height: 10.w),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      _buildFinanceButton(
                        '优惠券',
                        HomeImages.homeFinancialYhqPng,
                        false,
                      ),
                      SizedBox(width: 8.w),
                      _buildFinanceButton(
                        '我的积分',
                        HomeImages.homeFinancialWdjfPng,
                        false,
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }

  // 构建财务中心按钮
  Widget _buildFinanceButton(String label, String imagePath, bool isTop) {
    return Container(
      padding: EdgeInsets.all(10.w),
      width: isTop ? 175.w : 83.w,
      height: 70.w,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8),
        image: DecorationImage(image: AssetImage(imagePath), fit: BoxFit.cover),
      ),
      child: Text(label),
    );
  }
}
